﻿<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="Chat.ascx.vb" Inherits="Trebuchet.Chat" %>

 <script type="text/javascript">

     var scrolling

     function SetChatTextScrollPosition() {

         var chatText = $get("divChatText");

         if (!scrolling) {
             chatText.scrollTop = chatText.scrollHeight;
         }

         window.setTimeout("SetChatTextScrollPosition()", 1);

     }

     function DisableTimer() {

         var timer = $find('<%= tChatTimer.ClientID %>');

         scrolling = true

         timer.set_enabled(false);

         if (timer.get_enabled())
             timer._startTimer();
         else
             timer._stopTimer();
     }

     function EnableTimer() {
         var timer = $find('<%= tChatTimer.ClientID %>');

         scrolling = false

         timer.set_enabled(true);

         if (timer.get_enabled())
             timer._startTimer();
         else
             timer._stopTimer();
     }

     window.onload = function () {

         SetChatTextScrollPosition();

     }
             
</script>


    <asp:UpdatePanel ID="ChatUpdatePanel" runat="server" UpdateMode="Always">
<ContentTemplate>

<div id="divChatText" style="width: 640px; height: 240px; overflow: auto;" onmouseover="DisableTimer();" onmouseout="EnableTimer();">
<asp:BulletedList runat="server" ID="blChatMessageList" />
</div>

</ContentTemplate>
<Triggers>

<asp:AsyncPostBackTrigger ControlID="cmdSendButton" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="tChatTimer" EventName="Tick" />
</Triggers>
</asp:UpdatePanel>
Send Message Text<br/>
 
 <asp:UpdatePanel id="UpdatePanel1" runat="server" UpdateMode="Conditional">
 <ContentTemplate>
 <asp:TextBox ID="txtMessage" Columns="50" runat="server" />
 </ContentTemplate>
 </asp:UpdatePanel>
 

<asp:Button ID="cmdSendButton" Text="Send" runat="server"/>

<asp:Timer runat="server" ID="tChatTimer" Interval="5000" />

